package com.kcyu.sfherp.entity.utilEntity;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.kcyu.sfherp.entity.Chzd;
import lombok.Data;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class ExcelChzd {

    @ExcelProperty("单号")
    private String dh;

    @ExcelProperty("客户编号")
    private String khbh;
    @ExcelProperty("客户名称")
    private String khname;
    @ExcelProperty("金额")
    private Float je;
    @ExcelProperty("欠款")
    private Float qk;
    @ExcelProperty("付款方式")
    private String fkfs;

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @ExcelProperty("日期")
    @ColumnWidth(17)
    @ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.RIGHT)
    private Timestamp rq;

    public ExcelChzd() {}

    public ExcelChzd(Chzd chzd) {
        this.dh = chzd.getDh();
        this.khbh = chzd.getKhbh();
        this.khname = chzd.getKhname();
        this.je = chzd.getJe();
        this.qk = chzd.getQk();
        this.fkfs = chzd.getFkfs();
        this.rq = chzd.getRq();
    }

    public List<ExcelChzd> converts(List<Chzd> chzd) {
        List<ExcelChzd> excelChzds = new ArrayList<>();
        for (Chzd value : chzd) {
            ExcelChzd excelChzd = new ExcelChzd(value);
            excelChzds.add(excelChzd);
        }

        return excelChzds;
    }

}
